<template>
  <div class="wrap">
    <header>
      <span @click="go()">&lt;</span>
      <p>排行榜</p>
    </header>
    <main>
      <input type="text" placeholder="请输入要查询的经纪人" v-model="val" @input="search" />
      <div class="person">
        <div class="p1">
          <img src="../../img/p2.png" alt />
          <p>花生</p>
        </div>
        <div class="p2">
          <img src="../../img/p3.png" alt />
          <p>馒头</p>
        </div>
        <div class="p3">
          <img src="../../img/p4.png" alt />
          <p>土豆</p>
        </div>
      </div>
      <div class="list">
        <div v-for="(item,index) in list" :key="index" class="box">
          <span class="id">{{item.id}}</span>
          <img :src="item.img" alt @click="todetail(item)" />
          <div class="font">
            <span>{{item.name}}</span>
            <p>{{item.title}}</p>
          </div>
          <div class="aaa">
            <van-icon name="chat-o" @click="tointer()" />
            <van-icon name="phone-circle-o" @click="todianhua()" />
          </div>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import axios from "../../utils/request";
import debounce from "../../utils/debounce";
export default {
  data() {
    return {
      list: [],
      val: ""
    };
  },
  created() {
    this.getList();
  },
  methods: {
    go() {
      this.$router.go(-1);
    },
    async getList() {
      const res = await axios.post("/api/search1", { val: this.val });
      // console.log(res);
      this.list = res.data.data;
      // axios({
      //   url: "/api/getList",
      //   method: "post"
      // }).then(res => {
      //   // console.log(res);
      //   this.list = res.data.data;
      // });
    },

    //搜素name
    search() {
      debounce(() => {
        this.getList();
      }, 500);
    },

    //详情
    todetail(item) {
      this.$router.push(`/detail/${item.id}`);
    },

    tointer() {
      this.$router.push("/inter");
    },

    todianhua() {
      this.$router.push("/dianhua");
    }
  }
};
</script>

<style lang="scss" scoped>
.wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
header {
  width: 100%;
  height: 50px;
  display: flex;
  line-height: 50px;
  align-items: center;
  background: rgb(56, 121, 240);
  padding: 15px;
  color: #fff;
  p {
    padding-left: 38%;
  }
}
main {
  flex: 1;
  overflow-y: scroll;
  width: 100%;
  height: 250px;
  background: url("../../img/bj.png");
  input {
    width: 90%;
    margin: 10px 5%;
    height: 30px;
    line-height: 30px;
    border-radius: 3px;
    border: none;
    text-indent: 12px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.5);
  }
  .person {
    width: 90%;
    margin: 0 5%;
    display: flex;
    align-items: center;
    .p1 {
      width: 30%;
      height: 140px;
      background: #f1f1f1;
      align-items: center;
      text-align: center;
      border-radius: 10px 10px 0 0;
      margin-top: 60px;
      img {
        width: 65px;
        height: 65px;
        border-radius: 50%;
        margin-top: 20px;
      }
      p {
        font-size: 16px;
      }
    }
    .p2 {
      width: 37%;
      background: #f1f1f1;
      height: 170px;
      margin: 0 2%;
      margin-top: 30px;
      align-items: center;
      text-align: center;
      border-radius: 15px 15px 0 0;
      img {
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-top: 20px;
      }
      p {
        font-size: 16px;
      }
    }
    .p3 {
      width: 30%;
      height: 140px;
      background: #f1f1f1;
      align-items: center;
      text-align: center;
      border-radius: 10px 10px 0 0;
      margin-top: 60px;
      img {
        width: 65px;
        height: 65px;
        border-radius: 50%;
        margin-top: 20px;
      }
      p {
        font-size: 16px;
      }
    }
  }
  .list {
    background: #f1f1f1;
    .box {
      display: flex;
      align-items: center;
      .id {
        font-size: 14px;
        padding-left: 5%;
      }
      img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        margin: 10px 5%;
      }
      .font {
        align-items: center;
        margin-right: 20px;
        span {
          font-size: 15px;
          color: #333;
        }
        p {
          font-size: 14px;
          color: #999;
          padding-top: 5px;
        }
      }
      .van-icon {
        margin-left: 40px;
        color: rgb(219, 89, 89);
        background: rgb(241, 172, 172);
        border-radius: 50%;
        padding: 3px;
      }
      .van {
        margin-left: 60px;
        text-align: center;
        align-items: center;
        .van-icon {
          width: 25px;
          height: 25px;
          border-radius: 50%;
          background: rgba(231, 159, 159, 0.5);
          line-height: 25px;
          color: palevioletred;
          margin: 0 10px;
        }
      }
    }
  }
}
</style>